import Mock from 'mockjs'

import * as mUtils from '@/utils/mUtils'


let List = []
const count = 60
let typelist = [1, 2, 3, 4, 5, 6, 7, 8]

for (let i = 0; i < count; i++) {
  List.push(Mock.mock({
    id: Mock.Random.guid(),
    username: Mock.Random.cname(),
    address: Mock.mock('@county(true)'),
    createTime: Mock.Random.datetime(),
    income: Mock.Random.float(0, 9999, 2, 2),
    pay: Mock.Random.float(-5999, 0, 2, 2),
    accoutCash: Mock.Random.float(0, 9999, 2, 2),
    'incomePayType|1': typelist
  }))
}
let auditList = [{
  roId: "1002023",
  username: "1401901",
  cpName: "谜语01	",
  gameName: "西游伏魔录传（满V版）",
  serverName: "13服-幻灵13服",
  roleName: "花小",
  roleId: "1452692367688598468",
  amount: 99999,
  amountTotal: 999999,
  applyTime: "2019-05-09 16:06",
  payTime: "2019-05-09 16:06",
  remark: ""
}]
let rejectList = [{
  roId: "1002023",
  username: "1401901",
  cpName: "谜语01	",
  gameName: "西游伏魔录传（满V版）",
  serverName: "13服-幻灵13服",
  roleName: "花小",
  roleId: "1452692367688598468",
  amount: 99999,
  amountTotal: 999999,
  applyTime: "2019-05-09 16:06",
  payTime: "2019-05-09 16:06",
  remark: ""
}]
let checkList = [{
  roId: "1002023",
  username: "1401901",
  cpName: "谜语01	",
  gameName: "西游伏魔录传（满V版）",
  serverName: "13服-幻灵13服",
  roleName: "花小",
  roleId: "1452692367688598468",
  amount: 99999,
  amountTotal: 999999,
  applyTime: "2019-05-09 16:06",
  payTime: "2019-05-09 16:06",
  remark: "",
  auditRemark: ""
}]
let remarkList = [{
  roId: "1002023",
  username: "1401901",
  cpName: "谜语01	",
  remark: "",
  auditRemark: ""
}]
let extendList = [{
  roId: "1002023",
  username: "1401901",
  cpName: "谜语01	",
  gameName: "西游伏魔录传（满V版）",
  serverName: "13服-幻灵13服",
  roleName: "花小",
  roleId: "1452692367688598468",
  amount: 99999,
  amountTotal: 999999,
  applyTime: "2019-05-09 16:06",
  payTime: "2019-05-09 16:06",
  remark: ""
}]
export default {
  /**
   * 获取列表
   * 要带参数 name, page, limt; name可以不填, page,limit有默认值。
   * @param name, page, limit
   * @return {{code: number, count: number, data: *[]}}
   */
  getauditedData: config => {

    return {
      code: 200,
      data: {
        count: 20,
        list: auditList
      }
    }
  },
  getrejectData: config => {

    return {
      code: 200,
      data: {
        count: 20,
        list: rejectList
      }
    }
  },
  getcheckedData: config => {

    return {
      code: 200,
      data: {
        count: 20,
        list: checkList
      }
    }
  },
  getextendData: config => {
    return {
      code: 200,
      data: {
        count: 20,
        list: extendList
      }
    }
  },
  remarkAuditList: config => {
    return {
      code: 200,
      data: {
        count: 20,
        list: remarkList
      }
    }
  },
  giveOutInline: config => {
    const {
      name,
      page = 1,
      limit = 20
    } = mUtils.param2Obj(config.url)
    const mockList = List.filter(user => {
      if (name && user.username.indexOf(name) === -1) return false
      return true
    })
    const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    return {
      code: 200,
      data: {
        total: mockList.length,
        moneyList: pageList
      }
    }
  },
  onekeyExtend: config => {
    const {
      name,
      page = 1,
      limit = 20
    } = mUtils.param2Obj(config.url)
    const mockList = List.filter(user => {
      if (name && user.username.indexOf(name) === -1) return false
      return true
    })
    const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    return {
      code: 200,
      data: {
        total: mockList.length,
        moneyList: pageList
      }
    }
  },
  onekeyPass: config => {
    const {
      name,
      page = 1,
      limit = 20
    } = mUtils.param2Obj(config.url)
    const mockList = List.filter(user => {
      if (name && user.username.indexOf(name) === -1) return false
      return true
    })
    const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    return {
      code: 200,
      data: {
        total: mockList.length,
        moneyList: pageList
      }
    }
  },
  rejectInline: config => {
    const {
      name,
      page = 1,
      limit = 20
    } = mUtils.param2Obj(config.url)
    const mockList = List.filter(user => {
      if (name && user.username.indexOf(name) === -1) return false
      return true
    })
    const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    return {
      code: 200,
      data: {
        total: mockList.length,
        moneyList: pageList
      }
    }
  },
  passInline: config => {
    const {
      name,
      page = 1,
      limit = 20
    } = mUtils.param2Obj(config.url)
    const mockList = List.filter(user => {
      if (name && user.username.indexOf(name) === -1) return false
      return true
    })
    const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    return {
      code: 200,
      data: {
        total: mockList.length,
        moneyList: pageList
      }
    }
  },
  showrebateDetail: config => {
    const {
      name,
      page = 1,
      limit = 20
    } = mUtils.param2Obj(config.url)
    const mockList = List.filter(user => {
      if (name && user.username.indexOf(name) === -1) return false
      return true
    })
    const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    return {
      code: 200,
      data: {
        total: mockList.length,
        moneyList: pageList
      }
    }
  },
  remarkOrderPassBatch: config => {

  },
  remarkOrderPass: config => {

  },
  auditRemarkModify: config => {

  },
  memRemarkModify: config => {

  }
}
